import * as echarts from 'echarts'

function create(name, anaData){
    const chart = echarts.init(document.querySelector(name));

    let option = {
        title: {
            text: '每个类别的体积',
            subtext: '',
            left: 'center',
            textStyle: {
                color: 'white' // 设置标题文字颜色为红色
            },
        },
        tooltip: {
            trigger: 'item'
        },
        legend: {
            orient: 'vertical',
            left: 'left'
        },
        series: [
            {
                name: 'Access From',
                type: 'pie',
                radius: '50%',
                data: [],
                emphasis: {
                    itemStyle: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ]
    };

    for(let i in anaData.volume){
        let da = {}
        da.value = anaData.volume[i]
        da.name = i
        option.series[0].data.push(da)
    }

    chart.setOption(option)
}

export default {
    create
}